package com.mr.reducejoin;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Partitioner;

/*
 * 保证pId相同的key-value分到同一个区
 */

public class MyPartitioner extends Partitioner<NullWritable, JoinBean>{

	@Override
	public int getPartition(NullWritable key, JoinBean value, int numPartitions) {

		// 模仿HashPartitioner
		// pId相同，pId的哈希值就相同
		return (value.getpId().hashCode() & Integer.MAX_VALUE) % numPartitions;
	}

}
